package cn.z2huo.demo.hello.core.common;

import org.slf4j.MDC;

/**
 * <p>
 *
 * @author z2huo
 */
public final class TransactionCodeHolder implements HolderManager {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    private TransactionCodeHolder() {
    }

    public static String get() {
        return contextHolder.get();
    }

    public static void set(String transactionCode) {
        contextHolder.set(transactionCode);
        MDC.put("transactionCode", TransactionCodeHolder.get());
    }

    public static void clear() {
        contextHolder.remove();
    }

}
